Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

This is a thread.

Name: Anonymous 2007-04-25 6:13 ID:ipePewZ9

A thread, this is.

Name: Anonymous 2007-04-25 6:25 ID:cIf9CKRQ

pthread_exit(0);

Name: Anonymous 2007-04-25 6:35 ID:n2jiIQuG

mapM_ forkOS [1..]

Name: Anonymous 2007-04-25 6:37 ID:n2jiIQuG

hh, wait. mapM_ (const forkOS) [1..]

Name: Anonymous 2007-04-25 7:27 ID:Tbyybp1p

>>4
Is that sum for (;;) {fork();} ?

Name: Anonymous 2007-04-25 7:32 ID:Heaven

#define fuck fark
#define fark fork
#define fork fuck
int main(){for(;;){fark();}}

Name: Anonymous 2007-04-25 8:15 ID:nUwGSBn1

>>5
No. This is:

    main = forkOS main >>= (\_ -> main)

Name: Anonymous 2007-04-25 8:26 ID:n2jiIQuG

>>7
main = forkOS main >> main

Name: Anonymous 2007-04-25 9:52 ID:ipePewZ9

MOAR LIEK


class Thread
{
public:
    template<typename F>
    Thread(F f)
    {
        ThreadFunc<F>* func = new ThreadFunc<F>(f);
       
        _hThread = CreateThread(NULL, 0, ThreadProxy<ThreadFunc<F> >, func, NULL, NULL);
    }
    template<typename F, typename P>
    Thread(F f, P p)
    {
        ThreadFunc<F, P>* func = new ThreadFunc<F, P>(f, p);

        _hThread = CreateThread(NULL, 0, ThreadProxy<ThreadFunc<F, P> >, func, NULL, NULL);
    }
    template<typename F, typename P1, typename P2>
    Thread(F f, P1 p1, P2 p2)
    {
        ThreadFunc<F, P1, P2> *func = new ThreadFunc<F, P1, P2>(f, p1, p2);

        _hThread = CreateThread(NULL, 0, ThreadProxy<ThreadFunc<F, P1, P2>>, func, NULL, NULL);
    }
    ~Thread()
    {
        CloseHandle(_hThread);
    }

    void Lock()
    {
        SuspendThread(_hThread);
    }

    void WaitForQuit(DWORD timeout)
    {
        WaitForSingleObject(_hThread, timeout);
    }

    void Unlock()
    {
        ResumeThread(_hThread);
    }

private:
    template<typename F, typename P1 = void, typename P2 = void>
    struct ThreadFunc
    {
        F func;
        P1 param1;
        P2 param2;

        void operator()()
        {
            func(param1, param2);
        }

        ThreadFunc(F f, P1 p1, P2 p2)
            : func(f), param1(p1), param2(p2)
        {}
    };
    template<typename F, typename P>
    struct ThreadFunc<F, P, void>
    {
        F func;
        P param;

        void operator()()
        {
            func(param);
        }

        ThreadFunc(F f, P p)
            : func(f), param(p)
        {}
    };

    template<typename F>
    struct ThreadFunc<F, void, void>
    {
        F func;

        void operator()()
        {
            func();
        }

        ThreadFunc(F f)
            : func(f)
        {}
    };

    template<typename ThreadFunc>
    static DWORD WINAPI ThreadProxy(LPVOID param)
    {
        ThreadFunc* pF = (ThreadFunc*)param;
        (*pF)();

        delete param;

        return 0;
    }

    HANDLE _hThread;
};

class Mutex
{
public:
    Mutex()
    {
        InitializeCriticalSection(&_cSection);
    }
    ~Mutex()
    {
        DeleteCriticalSection(&_cSection);
    }
private:
    void Aquire()
    {
        EnterCriticalSection(&_cSection);
    }
    void Release()
    {
        LeaveCriticalSection(&_cSection);
    }

    friend class Lock;
    CRITICAL_SECTION _cSection;
};

class Event
{
public:
    Event()
    {
        _hEvent = CreateEvent(0, TRUE, FALSE, "");
    }
    ~Event()
    {
        CloseHandle(_hEvent);
    }

    void Set()
    {
        SetEvent(_hEvent);
    }
    void Pulse()
    {
        PulseEvent(_hEvent);
    }
    void Reset()
    {
        ResetEvent(_hEvent);
    }
    bool Wait(unsigned int numMs)
    {
        return WaitForSingleObject(_hEvent, numMs) == WAIT_OBJECT_0;
    }
private:
    HANDLE _hEvent;
};

class Lock
{
public:
    Lock(Mutex &mutex) : _mutex(mutex)
    {
        mutex.Aquire();
    }
    ~Lock()
    {
        _mutex.Release();
    }
private:
    Mutex &_mutex;
};

#endif

KEKEKEKE

Name: Anonymous 2007-04-25 10:28 ID:gnk1QEuE

I thought one of the cool things about functional programming was that the compiler could figure out when to use threads by itself?

Name: Anonymous 2007-04-25 11:30 ID:ipePewZ9

>>10
no lol

Name: Anonymous 2007-04-25 11:32 ID:zZvpYbf/

But Touring-complete? is it

Name: Anonymous 2007-04-25 12:23 ID:t+fCegix

Name: Anonymous 2007-04-25 13:41 ID:ipePewZ9

>>13
NO LOL

Name: Anonymous 2007-04-25 15:01 ID:n2jiIQuG

>>10
Haskell comes closest to that: you have to give it hints in the form of par and parMap, etc.

Name: Anonymous 2007-04-25 15:14 ID:LATKdVfL

>>9
C++ and Windows... writing more code to do less work.

#include <pthread.h>

Name: Anonymous 2007-04-25 15:31 ID:PqXKb29a

>>9
This is horrible and I want this code to go away.

Name: Anonymous 2007-04-25 17:39 ID:YK81PKAC

C++ and Windows... writing more code to do the same amount of work, but faster.

Name: Anonymous 2007-04-26 5:58 ID:XUihReaY

>>9
Lol Bill Gates

Name: Anonymous 2007-04-26 6:07 ID:I8MD8PDv

I'm >>9
Yes, my class implementation is alot longer than what you usually need for using threads C++ style - however, simply including the regular thread stuff only allows for simple functions to be used for the threads, which is a HUGE problem unless you want to write ugly C-style globalized code without the use of classes (or simply making the class variables globals or singletons). What this wrapper does is enable threading using class functions, which is awesome and useful.
And actually makes writing objectoriented programming using threads possible, without giving you major headache.
It's pretty much a must if you want to write a nice network wrapper..

Name: Anonymous 2007-04-26 6:24 ID:PsKFoHuK

>>20
Why the hell didn't you just use Boost.Threads?

Name: Anonymous 2007-04-26 7:03 ID:ck+MFhUA

>>21

NIH syndrome

Name: Anonymous 2007-04-26 8:48 ID:I8MD8PDv

>>21
Because it was an assignment for class

Name: Anonymous 2007-04-26 8:56 ID:qaUSdi2v

1-24 same person

It was me all the time.

Name: Anonymous 2007-04-26 9:55 ID:XUihReaY

>>20
C++ really really sucks if it treats methods differently from functions.

Name: Anonymous 2007-04-26 10:24 ID:PsKFoHuK

>>25
Java really really sucks if it makes you use OO for everything.  Multi-paradigm programming FTW.

Name: Anonymous 2007-04-26 10:38 ID:VumYoKx9

>>25
No, its awesome like that.

Name: Anonymous 2007-04-26 10:58 ID:Heaven

>>25
C++ really really sucks

Fixed

Name: Anonymous 2007-04-26 11:51 ID:VumYoKx9

>>28
HTML PRO

Name: Anonymous 2007-04-26 12:07 ID:PsKFoHuK

>>28
C++ is like democracy. It's crap, but the alternatives are worse. Your boss will never let you write Prolog/Scheme/Haskell, and C++ in a properly-trained programmer's hands (this is important) is better than Java, C, etc.  Of course, you get enough rope to hang yourself too.

Name: Anonymous 2007-04-26 12:13 ID:IJtnE//S

>>30
Of course my boss lets me write Haskell.

Name: Anonymous 2007-04-26 12:44 ID:Heaven

>>30
JScript .NET or C or GTFO

Name: Anonymous 2007-04-26 13:40 ID:Heaven

#!/usr/bin/env python
import thread


Say, wonder what happens if you try to start a thread with a class method... oh, that's right, it works.

Name: Anonymous 2007-04-26 14:48 ID:5HpkXUWZ

IT JUST WURKS KK!!! <3

Name: Anonymous 2007-04-26 16:11 ID:2tFWwB9G

>>23

wow, you sound gay.

Name: Anonymous 2007-04-26 16:39 ID:Heaven

pthread_detach();

Name: Anonymous 2007-04-27 2:43 ID:Dg8lNUlz

>>35
And you sound retarded, what's your point? :D

Name: Anonymous 2007-04-27 3:36 ID:BCpcNz/Y

CreateWindowsThreadInCurrentContext(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

Name: Anonymous 2007-04-27 3:40 ID:qaMePIrG

>>38
for(;;)
{
  cout << NULL
}

Name: Anonymous 2007-04-27 3:51 ID:BCpcNz/Y

>>39
OH FUCK THAT'S WINDOWS SOURCE CODE PREPARE TO BE SUED

Name: Anonymous 2007-04-27 4:05 ID:/BkUpqA8

>>40
i lold

Name: Anonymous 2007-04-27 17:15 ID:p1b7KE4u

Useful recipe for PyWin32: call a Windows function:

functionname(args, *[None] * 10000)

Name: Anonymous 2007-04-28 0:29 ID:z+tUYpzx

PUSH 1337                                                          
PUSH 0                                                   
PUSH 0                                                      
PUSH SPAM
PUSH 0
PUSH 0                                                
CALL DWORD PTR DS:[<&kernel32.CreateThread>]

Name: Anonymous 2007-04-28 5:40 ID:wLyWS6IW

PUSH 0
PUSH 0
PUSH 0
PUSH 0
PUSH 0
PUSH 0
PUSH 0
PUSH 0
PUSH 0
PUSH 0
PUSH 0
PUSH 0
PUSH 0
PUSH 0
PUSH 0
PUSH 0
PUSH 0
PUSH 0
PUSH 0
PUSH 0
PUSH 0
PUSH 0
PUSH 0
PUSH 0

Name: Anonymous 2009-01-14 12:31

LISP

Name: Anonymous 2010-12-22 23:14

Name: Anonymous 2011-02-03 8:33

Name: Anonymous 2011-02-04 13:24

Name: Sgt.Kabuᢥ疜kiman剠잇 2012-05-29 0:56

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List