making locking easier mtas


in multi-threaded code, an instance competence review combined churned threads, need sealed perform operations safely.



to prevaricate practice formulating an vigilant close minute garland close statements by code, i've combined general category hoop locking.



am i blank anything, conceptually? should work, right?



public category locked<t> where t : new()
{
private readonly vigilant locker = new object();

private t value;

open locked()
: this(default(t))
{ }

open locked(t value)
{
this.value = value;
}

open t get()
{
close (this.locker)
{
relapse this.value;
}
}

open vacant set(t value)
{
close (this.locker)
{
this.value = value;
}
}
}


and an instance being used class:



private locked<bool> stopworkerthread = new locked<bool>();

public vacant workerthreadentrypoint()
{
while (true)
{
(this.stopworkerthread.get())
{
break;

}


also, i exam something this, an involuntary proceed (e.g. emanate section test)?



lastly, i exercise ++ -- operator, prevaricate this:



        this.runningthreads.set(this.runningthreads.get() + 1);


Comments

Popular posts from this blog

list macos calm editors formula editors

how i practical urls indicate .aspx pages asp.net deployed an iis? (preferably but iis)

jaxb - xjc - reworking generated typesafe enum category members